const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    const content = [];
    for(let i = 0; i < 20; i++)
        content.push({
            id: `2019${i}`,
            code: `2019${i}`,
            brandCode: `00${i}`,
            brandName: `品牌${i}`,
            branchCode: '20119',
            dealerCode: `dealerCode${i}`,
            year: 7,
            amount: 123,
            currency: 1,
            status: 1,
            rowVersion: 'string',
            options: ['update', 'abandon']
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 20,
        }
    });
});

router.get('/:id', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                id: '20191',
                code: '20191',
                brandId: 'brandId',
                brandName: 'X品牌',
                brandCode: '品牌x',
                dealerId: 'dealerId1',
                dealerCode: 'dealerCode',
                dealerName: 'dealerName',
                currency: 1,
                year: 1,
                amount: 3123,
                rowVersion: 'string',
                options: ['update', 'abandon']
            }
        }
    );
});

router.put('/:id', (req, res) => {
    res.json(
        {
            message: '修改成功'
        }
    );
});

router.post('/', (req, res) => {
    res.json(
        {
            message: '提交成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

module.exports = router;
